using System;
using System.Collections.Generic;
using System.Text;

namespace Eve.Data
{
    public class ConstellationJump : EveAssociation<Constellation, Constellation>
    {
        private int fromRegionId;
        private int toRegionId;

        private Region fromRegion;
        private Region toRegion;

        public Constellation FromConstellation
        {
            get { return From; }
        }
        public Constellation ToConstellation
        {
            get { return To; }
        }
        public Region FromRegion
        {
            get
            {
                if (fromRegion == null)
                    fromRegion = new Region(db, fromRegionId);
                return fromRegion;
            }
        }
        public Region ToRegion
        {
            get
            {
                if (toRegion == null)
                    toRegion = new Region(db, toRegionId);
                return toRegion;
            }
        }

        internal ConstellationJump(DbDataRow dr)
            : base(dr.Database, new Constellation(dr.Database, dr["fromConstellationID"]), new Constellation(dr.Database, dr["toConstellationID"]))
        {
            Fill(dr);
        }

        private void Fill(DbDataRow dr)
        {
            fromRegionId = dr["fromRegionID"];
            toRegionId = dr["toRegionID"];
        }
    }
}
